//
// Created by vista on 2018/1/6.
//


#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <set>
using namespace std;

class Solution {
public:
    int strStr(string haystack, string needle) {
        int index = -1;
        if(haystack.size() < needle.size() )
            return index;
        for (int i = 0; i <= haystack.size() - needle.size(); ++i) {
            int j = 0;
            for (; j < needle.size(); ++j) {
                if(haystack[i+j] != needle[j])
                    break;
            }
            if(j == needle.size()){
                return i;
            }
        }
        return index;
    }

};

int main(){

    Solution solution;

    __uint64_t timebegin =  clock_gettime_nsec_np(CLOCK_REALTIME);

    vector<int> nums;
//    for (int i = 0; i < 100; ++i) {
//        nums.push_back(i);
//    }

    nums.push_back(3);
    nums.push_back(2);
    nums.push_back(2);
    nums.push_back(3);

    cout << solution.strStr("a","a") << endl;

    __uint64_t timeend =  clock_gettime_nsec_np(CLOCK_REALTIME);

    cout << (timeend - timebegin) / 1000000.0 << endl;

    return 0;

}